package com.tedu.egweibo.common.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 统一响应结果
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class JsonResult {
    private Integer status;
    private String msg;
    private Object data;

    public JsonResult(StatusCode status){
        this.status = status.getStatusCode();
        this.msg = status.getMessage();
    }

    public JsonResult(StatusCode status,Object data){
        this(status);
        this.data = data;
    }

    public static JsonResult success(Object data){
        return new JsonResult(StatusCode.OPERATION_SUCCESS,data);
    }

    public static JsonResult success(){
        return new JsonResult(StatusCode.OPERATION_SUCCESS);
    }
}
